local skel = fk.CreateSkill{
  name = "fm__zengqun",
}
--local U = require "packages/utility/utility"
Fk:loadTranslationTable{
  ["fm__zengqun"] = "赠囷",
  [":fm__zengqun"] = "回合开始时，你将牌堆顶的四张牌扣置于武将牌上，称为“囷”。其他角色回合开始时，你可以令其获得一半的“囷”"..
  "（向下取整但至少一张），你的手牌上限+X（X为“囷”的数量）。",
  ["$fm__zengqun"] = "囷",
  ["#fm__zengqun-invoke"] = "赠囷：你可以令 %src 获得一半的“囷”（向下取整但至少为1）",

  ["$fm__zengqun1"] = "筑仓廪以备饥馑之患。",
  ["$fm__zengqun2"] = "仓廪实而天下安。",
  ["$fm__zengqun3"] = "千金散尽不足惜！",
  ["$fm__zengqun4"] = "开仓与友，以济困厄。",
}
---@type TrigSkelSpec<TurnFunc>
local zengqun = {
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return player == target and player:hasSkill(skel.name)
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, skel.name, "support")
    player:broadcastSkillInvoke(skel.name, table.random{1, 2})
    local cids = room:getNCards(4)
    player:addToPile("$fm__zengqun", cids, false, skel.name, player, player.id)
  end
}
---@type TrigSkelSpec<TurnFunc>
local zengqun_trig = {
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return player ~= target and player:hasSkill(skel.name) and #player:getPile("$fm__zengqun") > 0 and not target.dead
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = skel.name,
      prompt = "#"..skel.name.."-invoke:" .. target.id
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cids = player:getPile("$fm__zengqun")
    room:notifySkillInvoked(player, skel.name, "support")
    player:broadcastSkillInvoke(skel.name, table.random{3, 4})
    local num = math.max(1, math.floor(#player:getPile("$fm__zengqun")/2))
    cids = table.random(cids, num)
    if #cids > 0 then
      room:obtainCard(target, cids, false, fk.ReasonJustMove, player, skel.name)
    end
  end
}
---@type MaxCardsSpec
local zengqun_maxcard = {
  correct_func = function (self, player)
    return #player:getPile("$fm__zengqun")
  end
}
skel:addEffect(fk.TurnStart, zengqun)
skel:addEffect(fk.TurnStart, zengqun_trig)
skel:addEffect("maxcards", zengqun_maxcard)
return skel